<template>
    <div style="height: 100%;margin: 0;padding: 0;">
        <div class="skip_container">
            <a class="skip">跳过看更多好货</a>
            <img src="../assets/login_right_arrow.png" width="6px" height="10px"/>
        </div>
        <!--    设置appear，表示渲染后马上执行动画，可以通过其他值设定动画执行类    -->
        <!--        <transition name="title-fade-in" appear enter-active-class="title-fade-in-active">-->
        <transition name="title-fade-in" appear type="animation">
            <div class="title_container">
                <p class="title">欢迎来到云集</p>
                <p class="title">请您登录/注册</p>
            </div>
        </transition>

        <!--    登录内容区域    -->
        <div class="login_content">
            <span>+86</span>
            <img src="../assets/login_down_arrow.png" width="10px" height="6px"
                 style="padding: 4px"/>
            <input type="text" placeholder="输入手机号码" v-model="phone" maxlength="11"
                   @input="inputChange" autofocus/>
            <img class="login_input_del" src="../assets/login_input_del.png" v-show="isShowDel"
                 @click="clearInput"/>
        </div>
        <button type="button" :class="{login_active: isActive}" @click="onLogin()">登录/注册</button>

        <!--   底部内容区域     -->
        <div class="bottom_content">
            <!--   底部第三方登录     -->
            <section id="third_login">
                <a style="font-size: 14px;color: #999999">其他登录方式</a>
                <ul>
                    <li v-for="item in loginChannels" class="login_channel">
                        <img :src="item.channelImg"/>
                        {{item.channelName}}
                    </li>
                </ul>
            </section>

            <!--    底部文案    -->
            <footer>
                <p>注册/登录即同意<a>云集平台服务协议</a>和<a>隐私政策</a></p>
            </footer>
        </div>
    </div>
</template>


<script>
    export default {
        name: "LoginView",
        data() {
            return {
                phone: "",
                isActive: false,
                isShowDel: false,
                loginChannels: [
                    {
                        channelName: "微信",
                        channelImg: require("../assets/login_wechat_icon.png")
                    },
                    {
                        channelName: "账号",
                        channelImg: require("../assets/login_account_icon.png")
                    }, {
                        channelName: "指纹",
                        channelImg: require("../assets/login_finger_icon.png")
                    }
                ]
            }
        },
        methods: {
            inputChange() {
                this.isShowDel = this.phone.length > 0;
                this.isActive = this.phone.length === 11;
            },
            onLogin() {
                if (!this.isActive) {
                    return;
                }
                this.$router.push("/main")
            },
            clearInput() {
                this.isShowDel = false;
                this.phone = ""
            }
        }
    }
</script>

<style scoped>
    /* 自定义字体 */
    @font-face {
        font-family: FZY4JW;
        src: url("../assets/FZY4JW.otf");
    }

    /* 自定义进入动画开始帧 */
    .title-fade-in-enter {
        /* 动画开始之前往下移10个px，同时透明度为0 */
        transform: translateY(10px);
        opacity: 0;
    }

    /* 自定义动画执行状态 */
    .title-fade-in-enter-active {
        /* 动画执行过程中设置全部属性均运用动画 */
        transition: all .3s ease;
        /* 为啥子不是用的transition-delay啊...而是用animation-delay */
        /* 估计是因为我动画支持延迟而已，我不想他的过度状态也延迟 */
        animation-delay: 2s;
    }

    /* 默认是Block */
    .skip_container {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        /* top right bottom left */
        padding: 10px 0 0 0;
        margin: 0 auto;
    }

    .skip {
        text-align: right;
        padding-right: 6px;
        font-size: 14px;
        color: #666666;
    }

    .title_container {
        margin-top: 60px;
    }

    .title {
        color: #666666;
        font-size: 26px;
        line-height: 8px;
        text-align: left;
        margin-left: 10px;
        letter-spacing: 3px;
        font-family: FZY4JW;
    }

    .login_content {
        display: flex;
        align-items: center;
        margin: 40px 10px 10px 10px;
        flex-flow: row wrap;
        justify-content: flex-start;
    }

    .login_content .login_input_del {
        width: 12px;
        height: 12px;
        margin-right: 10px;
    }

    input {
        background: white;
        height: 20px;
        border: none;
        padding-left: 4px;
        outline: none;
        caret-color: hotpink;
        font-size: 16px;
        width: 200px;
        flex-grow: 1;
    }

    input::-webkit-input-placeholder {
        color: #cccccc;
        font-size: 16px;
    }

    button {
        background: #FFCCCC;
        outline: none;
        width: 94%;
        border: none;
        color: white;
        height: 36px;
        font-family: FZY4JW;
        border-radius: 25px;
        margin: 10px;
    }

    .login_active {
        background: #F10D3B;
    }

    .bottom_content {
        width: 100%;
        position: absolute;
        bottom: 0;
    }

    section {
        display: flex;
        padding: 0 16px;
        flex-direction: column;
        justify-content: flex-start;
    }

    section a {
        text-align: left;
    }

    section ul {
        margin: 10px 0;
        padding: 0;
        list-style: none;
        display: flex;
    }

    section li {
        margin-right: 26px;
        display: inline-block;
        color: #333333;
        font-size: 12px;
    }

    section img {
        width: 30px;
        height: 30px;
        margin-bottom: 10px;
        display: block;
    }

    footer {
        font-size: 10px;
        color: #cccccc;
        position: sticky;
    }

    footer a {
        color: #666666;
        margin: 0 2px;
        text-decoration: underline;
        text-underline: #666666;
        cursor: pointer;
    }

</style>
